package com.sdruixinggroup.mondayb2b.ui.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sdruixinggroup.mondayb2b.R;
import com.sdruixinggroup.mondayb2b.models.OrderInfor;
import com.sdruixinggroup.mondayb2b.widget.BigPicDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 00029935 on 2018/1/20.
 */

public class OffLineDetialFragment extends BaseFragment {
    @BindView(R.id.ib_back)
    ImageView ibBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_pic)
    ImageView ivPic;
    @BindView(R.id.tv_order)
    TextView tvOrder;
    @BindView(R.id.tv_nonghu)
    TextView tvNonghu;
    @BindView(R.id.tv_count)
    TextView tvCount;
    private  OrderInfor.OrderBean orderBean;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        orderBean = (OrderInfor.OrderBean)getActivity().getIntent().getSerializableExtra("object");
    }

    @Override
    protected int getInflateLayout() {
        return R.layout.offline_detial_fragment_layout;
    }

    @Override
    protected void setUpView(View view) {
        tvTitle.setText("订货审核");
        Glide.with(getActivity()).load(orderBean.remittance.getPic()).into(ivPic);
        setTextViewColor(tvOrder,"订单号",orderBean.remittance.getOrder().getOrder_sn());
        setTextViewColor(tvNonghu,"农户&emsp",orderBean.remittance.getAgent().getUsername());
        setTextViewColor(tvCount,"订货量", String.valueOf(orderBean.remittance.getOrder().getGoods_count()));
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @OnClick({R.id.ib_back, R.id.iv_pic})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ib_back:
                getActivity().finish();
                break;
            case R.id.iv_pic:
                BigPicDialog bigPicDialog = new BigPicDialog();
                bigPicDialog.show(getFragmentManager(), orderBean.remittance.getPic());
                break;
        }
    }


    private void setTextViewColor(TextView textView,String name ,String value){

        textView.setText(Html.fromHtml( "<font color= '#333333'>"+name + "</font> "   +"<font color= '#666666'>"+value + "</font> "));
    }
}
